package com.CoreryBlack.service.Impl;

import com.CoreryBlack.Mapper.EmpExprMapper;
import com.CoreryBlack.Mapper.EmpLogMapper;
import com.CoreryBlack.Mapper.EmpMapper;
import com.CoreryBlack.po.*;
import com.CoreryBlack.service.EmpLogService;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

@Service
public  class EmpLogServiceImpl implements EmpLogService {

    @Autowired
    private EmpLogMapper empLogMapper;
    @Autowired
    private EmpMapper empMapper;
    @Autowired
    private EmpExprMapper empExprMapper;

    @Transactional(propagation = Propagation.REQUIRES_NEW) //事务的传播行为，REQUIRES_NEW：开启一个新事务
    public void insertLog(EmpLog empLog) {
        empLogMapper.insert(empLog);
    }

    @Override
    public void update(Emp emp) {

    }

    @Override
    public PageBean list(EmpLogQueryParam empLogQueryParam) {
        PageHelper.startPage(empLogQueryParam.getPage(),empLogQueryParam.getPageSize());
        Page page1 = empLogMapper.list(empLogQueryParam);
        return new PageBean(page1.getTotal(),page1.getResult());
    }

}
